import 'dart:async';
import 'dart:io';

import 'package:flutter/services.dart';
import 'package:riki_push/enum/phone_platform.dart';
import 'package:riki_push/factory/riki_base_push.dart';
import 'package:riki_base_flutter/riki_base_flutter.dart';

///
///  华为推送
///
class RikiHwPush {
  static const MethodChannel _channel_hw = const MethodChannel('riki_push_hw');

  /// 获取华为token
  static Future<String> get hwToken async {
    String token = '';
    if (Platform.isAndroid && await RikiBasePush.phonePlatform == PhonePlatform.huawei) {
      token = await _channel_hw.invokeMethod('getToken');
    }
    LogUtil.v("华为token是" + (token == null ? 'null' : token));
    return token;
  }

  /// 删除华为token
  static Future<void> get deleteHwToken async {
    if (Platform.isAndroid && await RikiBasePush.phonePlatform == PhonePlatform.huawei) {
      return await _channel_hw.invokeMethod('deleteToken');
    }
  }
}
